package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzTjfy;
import com.ruoyi.system.service.IDzTjfyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 推荐房源Controller
 * 
 * @author ruoyi
 * @date 2023-09-15
 */
@RestController
@RequestMapping("/system/tjfy")
public class DzTjfyController extends BaseController
{
    @Autowired
    private IDzTjfyService dzTjfyService;

    /**
     * 查询推荐房源列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzTjfy dzTjfy)
    {
        startPage();
        List<DzTjfy> list = dzTjfyService.selectDzTjfyList(dzTjfy);
        return getDataTable(list);
    }

    /**
     * 导出推荐房源列表
     */
    @Log(title = "推荐房源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzTjfy dzTjfy)
    {
        List<DzTjfy> list = dzTjfyService.selectDzTjfyList(dzTjfy);
        ExcelUtil<DzTjfy> util = new ExcelUtil<DzTjfy>(DzTjfy.class);
        util.exportExcel(response, list, "推荐房源数据");
    }

    /**
     * 获取推荐房源详细信息
     */
    @GetMapping(value = "/{tfId}")
    public AjaxResult getInfo(@PathVariable("tfId") Long tfId)
    {
        return AjaxResult.success(dzTjfyService.selectDzTjfyByTfId(tfId));
    }

    /**
     * 新增推荐房源
     */
    @Log(title = "推荐房源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzTjfy dzTjfy)
    {
        return toAjax(dzTjfyService.insertDzTjfy(dzTjfy));
    }

    /**
     * 修改推荐房源
     */
    @Log(title = "推荐房源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzTjfy dzTjfy)
    {
        return toAjax(dzTjfyService.updateDzTjfy(dzTjfy));
    }

    /**
     * 删除推荐房源
     */
    @Log(title = "推荐房源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tfIds}")
    public AjaxResult remove(@PathVariable Long[] tfIds)
    {
        return toAjax(dzTjfyService.deleteDzTjfyByTfIds(tfIds));
    }
}
